﻿<?php
class FrontController {
    
    private $params;
    private static $frontController;
    private $view;
    private $user;

    private function __construct() {
    
        $this->params = $_REQUEST;
        $this->view = new View();
        
        $userMapper = new UserMapper();
        $this->user = $userMapper->getCurrentUser();
    }
    
    public static function instance() {
    
        if (self::$frontController == null) {
            self::$frontController = new FrontController();
        }
        return self::$frontController;
    }
    
    public function run() {
        
        $actionController = ActionControllerFabric::getController($this->params, $this->view, $this->user);
        $actionController->run();
        $this->view->render();
    }
}


?>